﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SuperSocket.SocketBase;
using SuperWebSocket;

namespace WebCommand
{
    public class MyServer : WebSocketServer<MySession>
    {
        public object SyncObj = new object();

        public MySession GetSessionByUserName(string username)
        { 
            return GetSessions(m=> m.UserName == username).SingleOrDefault() as MySession;
        }

        public List<MySession> GetAllSession()
        {
            return GetSessions(m => true).ToList();
        }

        protected override void OnNewSessionConnected(MySession session)
        {
            base.OnNewSessionConnected(session);
            session.SendResponseAsync("CONNECTED");
        }
    }
}
